package org.springframework;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.bean.User;
import org.springframework.beans.BeanUtils;

import java.beans.*;

public class IntrospectorTest {

	Logger log = LoggerFactory.getLogger(BeanDefinitionTest.class);

	@Test
	public void testIntrospect1() throws IntrospectionException {
		BeanInfo beanInfo = Introspector.getBeanInfo(User.class);
		BeanDescriptor beanDescriptor = beanInfo.getBeanDescriptor();
		log.info("beanDescriptor -> {}", beanDescriptor.getName());

		PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
		log.info("propertyDescriptors -> {}", propertyDescriptors.length);
		for (PropertyDescriptor descriptor : propertyDescriptors) {
			log.info("name -> {}", descriptor.getName());
			log.info("readMethod -> {}", descriptor.getReadMethod());
			log.info("writeMethod -> {}", descriptor.getWriteMethod());
			log.info("descriptorString -> {}", descriptor.getPropertyType().descriptorString());
		}

	}

}
